package com.chao.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.chao.common.valid.GroupAdd;
import com.chao.common.valid.GroupUpdate;
import com.chao.common.valid.GroupUpdateStatus;
import com.chao.common.valid.ListValue;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *
 * @author chao
 * @email chaochao@gmail.com
 * @date 2020-07-15 15:34:46
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @Null(message = "新增不能指定品牌id", groups = {GroupAdd.class})
    @NotNull(message = "修改必须指定品牌id", groups = {GroupUpdate.class})
    @TableId
    private Long brandId;
    /**
     * 品牌名
     */
    @NotBlank(message = "品牌名必须填写", groups = {GroupAdd.class, GroupUpdate.class})
    private String name;
    /**
     * 品牌logo地址
     */
    @NotBlank(message = "不能为空", groups = {GroupAdd.class})
    @URL(message = "Logo必须是一个合法的URL地址", groups = {GroupAdd.class, GroupUpdate.class})
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @NotNull(groups = {GroupUpdateStatus.class})
    @ListValue(chao_Vals = {0, 1}, groups = {GroupAdd.class, GroupUpdateStatus.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    @NotEmpty(message = "不能为空", groups = {GroupAdd.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {GroupAdd.class, GroupUpdate.class})
    private String firstLetter;
//   regexp 正则前后斜杠  java后端写是不需要的 /^[a-zA-Z]$/
    /**
     * 排序
     */
    @NotNull(message = "不能为空", groups = {GroupAdd.class})
    @Min(value = 0, message = "排序必须大于等于零", groups = {GroupAdd.class, GroupUpdate.class})
    private Integer sort;



}
